//#include <stdio.h>
//#include <stdlib.h>

//#include "hmac_sha1.h"
#include "../sysdef.h"


void PRF(u8 *key, 	u32 key_len,
         u8 *prefix, u32 prefix_len,
         u8 *data, 	u32 data_len,
         u8 *output, u32 len)
{
	u32 i;
	u8 input[1024]; /* concatenated input */
	u32 currentindex = 0;
	u32 total_len;
	
	memcpy(input, prefix, prefix_len);
	input[prefix_len] = 0; /* single octet 0 */
	
	memcpy(&input[prefix_len + 1], data, data_len);
	
	total_len = prefix_len + 1 + data_len;
	input[total_len] = 0;	/* single ocete count, starts at 0 */
	total_len++;
	
	for (i=0; i < (len+19)/20; ++i)
	{
		hmac_sha1(input, total_len, 
		          key,   key_len,
		          &output[currentindex]);
		currentindex += 20; /* next concatenation location */
		input[total_len-1]++; /* increment octet count */
	}
}

#define BUFLEN 4096


